﻿@model Jb.Web.ViewModels.UtilityModels.ListConfig
@using Jb.Web.Utility;
@using Jb.Common.Extensions;

@{    
    String pageTitle = "List of Favorite Jobs";
    ViewBag.Title = Html.GetPageTitle(pageTitle);
    int _TotalJobs = Model.DataSource.Rows.Count;
    ViewData[AppConstants.ViewDataKeys.SELECTED_MENU] = JobSeekerMenu.FaboriteJobs;
    ViewData[AppConstants.ViewDataKeys.REMOVE_FROM_FAVORITE] = true;
}
<div class="jb-page-heading">
    <h1>@pageTitle</h1>
    <div>
        Manage your fovorite jobs.
    </div>
</div>
<div id="divTopContainer" class="jb-page-content auto">    
    <div id="divMessage"></div>
    @if(_TotalJobs <= 0){
        @Html.InfoMessageBox("You haven't add any job to your favorite job list. You can add job to your favorite job list from any job listing.", "Info")
    }
</div>

@Html.Partial("_JobList", Model.DataSource)

@{
String autoClass = _TotalJobs > 0 ? "auto" : String.Empty;
<div class="jb-page-content @(autoClass)">

</div>
}

@*Delete Confirmation Modal Popup Section Start*@
<div id="divConfirmDialog" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="divPhotoEditModalLabel" aria-hidden="true">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">X</button>
        <h4 id="myModalLabel">Confirm Remove</h4>
    </div>
    <div class="modal-body jb-inline-label">            
        <div id="divModalMesssage">Are sure you want to remove this job from favorites?</div>
    </div>
    <div class="modal-footer">               
        <button type="button" class="btn btn-primary" onclick="DeleteFromFavoriteJob();"><i class="icon-remove icon-white"></i> Remove</button>
        <button class="btn" data-dismiss="modal" aria-hidden="true"><i class="icon-off"></i> Cancel</button>
    </div>
</div>
@*Delete Confirmation Modal Popup Section End*@

@Html.Partial("_SendToFriendModal")



@section JavaScriptPlaceHolder
{
@Html.JavaScript("jquery.validate.min.js", Url)
@Html.JavaScript("jquery.validate.unobtrusive.min.js", Url)
@Html.Partial("_SendToFriendJS")

<script language="javascript" type="text/javascript">
    var _DeleteAnchor = null, _DeleteJobID = 0;
    function RemoveFromFavorite(jobID, anchor) {
        _DeleteAnchor = anchor; _DeleteJobID = jobID;
        $('#divConfirmDialog').modal({ show: true });
    }
    function DeleteFromFavoriteJob() {
        $('#divConfirmDialog').modal('hide');
        ShowLoadingAnimation(false);
        Ajax('@Url.JobSeekerUrl("DeleteJobFromFavorite", "Job")', 'jobID=' + _DeleteJobID, function (result) {
            HideLoadingAnimation();
            var status = (parseInt(result));
            if (status > 0) {
                $(_DeleteAnchor).parent().parent().slideUp('slow');
                var favoriteJobCount = parseInt($('#span_LM_Favorite_Jobs').html());
                if(favoriteJobCount <= 1)
                    $('#divTopContainer').removeClass('auto');
                $('#span_LM_Favorite_Jobs').html(favoriteJobCount - 1);
            }
            $('#divMessage').html(BuildDeleteMessage(status));
        });
    }
    function BuildDeleteMessage(status) {
        var html = '';
        if (status > 0)
            html = SuccessMessageBox("Success! The job removed successfully from your favorite job list.");
        else if (status == -1)
            html = WarningMessageBox("Sorry! We couldn't remove this job from your favorite job list.");
        else if(status == -2)
            html = WarningMessageBox("Sorry! The requested job was not found in your favorite job list.");
        return html;
    }
</script>
}



    


